<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>app/helpers/xml_helper.rb</title>
    <link href="screen.css" media="all" rel="stylesheet" type="text/css" />
    <link href="print.css" media="print" rel="stylesheet" type="text/css" />
    
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <script type="text/javascript" src="rcov.js"></script>
  </head>
  <body>
    <h1>Survey0 3 C0 Coverage Information - RCov</h1>
    <h2>app/helpers/xml_helper.rb</h2>

    

    <div class="report_table_wrapper">
      <table class='report' id='report_table'>
        <thead>
          <tr>
            <th class="left_align">Name</th>
            <th class="right_align">Total Lines</th>
            <th class="right_align">Lines of Code</th>
            <th class="left_align">Total Coverage</th>
            <th class="left_align">Code Coverage</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td class="left_align"><a href="app-helpers-xml_helper_rb.html">app/helpers/xml_helper.rb</a></td>
            <td class='right_align'><tt>56</tt></td>
            <td class='right_align'><tt>39</tt></td>
            <td class="left_align"><div class="percent_graph_legend"><tt class=''>64.29%</tt></div>
          <div class="percent_graph">
            <div class="covered" style="width:64px"></div>
            <div class="uncovered" style="width:36px"></div>
          </div></td>
            <td class="left_align"><div class="percent_graph_legend"><tt class=''>53.85%</tt></div>
          <div class="percent_graph">
            <div class="covered" style="width:54px"></div>
            <div class="uncovered" style="width:46px"></div>
          </div></td>
          </tr>
        </tbody>
      </table>
    </div>
    
    <h3>Key</h3>
    
    <div class="key"><pre><span class='marked'>Code reported as executed by Ruby looks like this...</span><span class='marked1'>and this: this line is also marked as covered.</span><span class='inferred'>Lines considered as run by rcov, but not reported by Ruby, look like this,</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).</span><span class='uncovered'>Finally, here's a line marked as not executed.</span></pre></div>

    <h3>Coverage Details</h3>

    <table class="details">
      <tbody>
        
          
          
          <tr class="marked">
            <td><pre><a name="line1">1</a> module XmlHelper</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line2">2</a>   # This function helps you escape special characters in XML attribute values</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line3">3</a>   # Here, we have escaped only single quotes for xml attribute values</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line4">4</a>   # You can escape other characters which might be causing issues as xml attribute values</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line5">5</a>   def XmlHelper.escape_xml_attribute_values(string_to_escape,for_data_url)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line6">6</a>     escaped_str= string_to_escape</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line7">7</a>     # In case of inline xml, we need to escape the single quotes</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line8">8</a>     if for_data_url==false</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line9">9</a>       escaped_str = escaped_str.gsub(%r{'},'%26apos;');</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line10">10</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line11">11</a>     # Common Replacements</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line12">12</a>     # In Ruby On Rails, the builder automatically escapes &lt; , &gt;, %</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line13">13</a>     # Hence these replacements are not required</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line14">14</a>     </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line15">15</a>     #We've not considered any special characters here. </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line16">16</a>     #You can add them as per your language and requirements.</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line17">17</a>     return escaped_str</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line18">18</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line19">19</a>    # This function escapes the double quotes</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line20">20</a>   def XmlHelper.escape_double_quotes(str_to_escape)</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line21">21</a>     # Hash containing the required conversion</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line22">22</a>     conversions = {</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line23">23</a>        %r{&quot;}=&gt;'&amp;quot;'</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line24">24</a>     }  </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line25">25</a>     escaped_str = str_to_escape</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line26">26</a>     conversions.each do |x,y|</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line27">27</a>       escaped_str = escaped_str.gsub(x,y)</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line28">28</a>     end  </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line29">29</a>     return escaped_str</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line30">30</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line31">31</a>   # This function escapes the single quotes</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line32">32</a>   def XmlHelper.escape_single_quotes(str_to_escape)</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line33">33</a>     # Hash containing the required conversion</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line34">34</a>     conversions = {</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line35">35</a>        %r{'}=&gt;'%26apos;'</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line36">36</a>     }  </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line37">37</a>     escaped_str = str_to_escape</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line38">38</a>     conversions.each do |x,y|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line39">39</a>       escaped_str = escaped_str.gsub(x,y)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line40">40</a>     end  </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line41">41</a>     return escaped_str</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line42">42</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line43">43</a>    </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line44">44</a>    #The builder also encloses attribute values in double quotes. We will replace them with single quotes.</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line45">45</a>    def XmlHelper.escape_builder_xml(xml_to_escape)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line46">46</a>     # Hash containing all the required conversions</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line47">47</a>       conversions = {</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line48">48</a>       %r{&quot;}=&gt;'\''</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line49">49</a>      }  </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line50">50</a>       escaped_xml = xml_to_escape</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line51">51</a>       conversions.each do |x,y|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line52">52</a>           escaped_xml = escaped_xml.gsub(x,y)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line53">53</a>         end  </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line54">54</a>         return escaped_xml</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line55">55</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line56">56</a> end</pre></td>
          </tr>
        
      </tbody>
    </table>

    <p>Generated on Wed Mar 17 14:12:44 +0800 2010 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>

  </body>
</html>
